// 联网查询地址
const url_get_room_all = 'http://localhost:8085/room/all';
const url_get_user_money = 'http://localhost:8085/user/name?username=';

// eslint-disable-next-line no-unused-vars
async function http_get_room_all() {
    let ret_data = []
    await fetch(url_get_room_all, {
        method: 'GET',
        headers: {
            'Content-Type': 'application/json',
            'X-Custom-Header': 'foobar'
        }
    })
        .then(response => {
            if (!response.ok) {
                throw new Error('网络请求!ok');
            }
            return response.json();
        })
        .then(data => {
            // console.log("请求成功", data)
            // eslint-disable-next-line no-undef
            for (let i = 0; i < data.data.length; i++) {
                // eslint-disable-next-line no-undef
                ret_data.push(extractProperties(data.data[i]))
            }
        })
        .catch(error => {
            console.error('错误请求数据', error);
        });
    return ret_data
}


var user_money = 0;
// eslint-disable-next-line no-unused-vars
async function http_get_user_money(username) {
    await fetch(`${url_get_user_money}${username}`, {
        method: 'GET',
        headers: {
            'Content-Type': 'application/json',
            'X-Custom-Header': 'foobar'
        }
    })
        .then(response => {
            if (!response.ok) {
                throw new Error('网络请求!ok');
            }
            return response.json();
        })
        .then(data => {
            console.log("请求成功", data.data.userMoney)
            user_money = data.data.userMoney
        })
        .catch(error => {
            console.error('错误请求数据', error);
        });
    return user_money
}

